<!DOCTYPE html>
<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">


    <title> - Bootstrap Table</title>
    <meta name="keywords" content="">
    <meta name="description" content="">

    <link rel="shortcut icon" href="favicon.ico">
    <link href="{{ asset('admin/css/bootstrap.min.css?v=3.3.6') }}" rel="stylesheet">
    <link href="{{ asset('admin/css/font-awesome.css?v=4.4.0') }}" rel="stylesheet">
    <link href="{{ asset('admin/css/plugins/bootstrap-table/bootstrap-table.min.css') }}" rel="stylesheet">
    <link href="{{ asset('admin/css/animate.css') }}" rel="stylesheet">
    <link href="{{ asset('admin/css/style.css?v=4.1.0') }}" rel="stylesheet">


</head>

<body class="gray-bg">

<div class="col-sm-12 wrapper wrapper-content animated fadeInRight">
    <div class="ibox float-e-margins">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>新增</h5>
                    <div class="ibox-tools">

                    </div>
                </div>
                <div class="ibox-content">
                    <div class="row">
                        <div class="col-sm-12">
                            <form role="form" method="post" action="{{ route('admin.vpn.update', $vpn->id) }}" enctype="multipart/form-data">
                                <input type="hidden" name="id" value="{{$vpn->id}}">
                                {{method_field('put')}}
                                @csrf
                                <div class="form-group">
                                    <label>LOGO</label>
                                    <input name="image" type="file" id="upload" required="">
                                    <img id="yl" src="{{ $vpn->image }}"/>
                                    @error('image')
                                    <span class="invalid-feedback" role="alert">
                                        <strong>{{ $message }}</strong>
                                    </span>
                                    @enderror
                                </div>
                                <div class="form-group">
                                    <label>名称</label>
                                    <input name="name" placeholder="请输入名称" value="{{ $vpn->name ??  old('name') }}"
                                           class="form-control" required="">
                                    @error('name')
                                    <span class="invalid-feedback" role="alert">
                                        <strong>{{ $message }}</strong>
                                    </span>
                                    @enderror
                                </div>
                                <div class="form-group">
                                    <label>会员等级</label>
                                    <select class="form-control m-b" name="level_id">
                                        <option value="">请选择</option>
                                        @foreach($levels as $level)
                                            <option value="{{ $level->id }}"  @if($vpn->level_id == $level->id) selected @endif >{{ $level->name }}</option>
                                        @endforeach
                                    </select>
                                </div>
                                <div class="form-group">
                                    <label>服务器</label>
                                    <input name="serverhost" placeholder="请输入权重" value="{{ $vpn->serverhost ?? old('serverhost') }}"
                                           class="form-control" required="">
                                    @error('serverhost')
                                    <span class="invalid-feedback" role="alert">
                                        <strong>{{ $message }}</strong>
                                    </span>
                                    @enderror
                                </div>
                                <div class="form-group">
                                    <label>远程ID</label>
                                    <input name="remote_id" placeholder="请输入权重" value="{{ $vpn->remote_id ?? old('remote_id') }}"
                                           class="form-control" required="">
                                    @error('remote_id')
                                    <span class="invalid-feedback" role="alert">
                                        <strong>{{ $message }}</strong>
                                    </span>
                                    @enderror
                                </div>
                                <div class="form-group">
                                    <label>账号</label>
                                    <input name="username" placeholder="请输入权重" value="{{ $vpn->username ?? old('username') }}"
                                           class="form-control" required="">
                                    @error('username')
                                    <span class="invalid-feedback" role="alert">
                                        <strong>{{ $message }}</strong>
                                    </span>
                                    @enderror
                                </div>
                                <div class="form-group">
                                    <label>密码</label>
                                    <input name="password" placeholder="请输入权重" value="{{  $vpn->password ?? old('password') }}"
                                           class="form-control" required="">
                                    @error('password')
                                    <span class="invalid-feedback" role="alert">
                                        <strong>{{ $message }}</strong>
                                    </span>
                                    @enderror
                                </div>
                                <div class="form-group">
                                    <label>描述</label>
                                    <textarea name="description" placeholder="请输入权重" class="form-control"
                                              required=""> {{  $vpn->description ?? old('description') }} </textarea>
                                    @error('description')
                                    <span class="invalid-feedback" role="alert">
                                        <strong>{{ $message }}</strong>
                                    </span>
                                    @enderror
                                </div>

                                <div>
                                    <button class="btn btn-sm btn-primary pull-right m-t-n-xs" type="submit">
                                        <strong>保存</strong></button>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>


<!-- 全局js -->
<script src="{{ asset('admin/js/jquery.min.js?v=2.1.4') }}"></script>
<script src="{{ asset('admin/js/bootstrap.min.js?v=3.3.6') }}"></script>
<script>
    $('#upload').on('change', function (e, tag) {
        var fileList = this.files;
        var reader = new FileReader();
        //获取第一张图片，读取文件转base64
        reader.readAsDataURL(fileList [0]);
        reader.onload = function () {
            //用户上传的图片
            $("#yl").attr('src', this.result)
        };
    })
</script>

</body>

</html>
